﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Admin.Core.Common.Input;
using Admin.Core.Common.Output;
using Admin.Core.Common.ParamInput;
using Admin.Core.Model.Warehouse;
using Admin.Core.Service.Warehouse.XbcLocation;
using Admin.Core.Service.Warehouse.XbcLocation.Input;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Admin.Core.Controllers.Warehouse
{
    public class XbcLocationController : AreaController
    {

        private readonly IXbcLocationService _xbcLocationService;

        public XbcLocationController(IXbcLocationService xbcLocationService)
        {
            _xbcLocationService = xbcLocationService;
        }



        /// <summary>
        /// 查询单条库位信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> Get(long id)
        {
            return await _xbcLocationService.GetAsync(id);
        }


        /// <summary>
        /// 分页查询库位信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> GetPage(PageInput<XbcLocationFilterInput> model)
        {
            return await _xbcLocationService.PageAsync(model);
        }


        /// <summary>
        /// 根据物料类型寻找库位下拉
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> GetLocationList(long id)
        {
            return await _xbcLocationService.GetLocationListAsync(id);
        }


        /// <summary>
        /// 新增库位
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> Add(XbcLocationAddInput input)
        {
            return await _xbcLocationService.AddAsync(input);
        }

        /// <summary>
        /// 修改库位
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> Update(XbLocationUpdateInput input)
        {
            return await _xbcLocationService.UpdateAsync(input);
        }


        /// <summary>
        /// 删除库位
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IResponseOutput> SoftDelete(long id)
        {
            return await _xbcLocationService.SoftDeleteAsync(id);
        }

        /// <summary>
        /// 批量删除库位
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> BatchSoftDelete(long[] ids)
        {
            return await _xbcLocationService.BatchSoftDeleteAsync(ids);
        }


    }
}